set -xe
export build_njobs=${build_njobs:-20}

bazel build --jobs ${build_njobs} -c opt --strip=always //cc/appcoin2/strategy/rmm:rmm_runner && \
bazel build --jobs ${build_njobs} -c opt --strip=always //cc/appcoin2/strategy/rmm:genoi_runner

COIN_ROOT="$(git rev-parse --show-toplevel)"
COIN_BINARY_ROOT=$COIN_ROOT/../coin_binary

function deploy_coin2_app {
  mkdir -p $COIN_BINARY_ROOT/coin2-bazel-bin-3.10/$1
  rsync -avh --delete -L $COIN_ROOT/bazel-bin/$1/$2 $COIN_BINARY_ROOT/coin2-bazel-bin-3.10/$1/
}

set -x
deploy_coin2_app cc/appcoin2/strategy/rmm rmm_runner
deploy_coin2_app cc/appcoin2/strategy/rmm genoi_runner

echo "Build and Copy to coin_binary Successfully!!"
echo "You must push your binary by using git lfs later!!"
